<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
<div id="pie" style="width: 500px;height:400px;float:right"></div>
<script src="/javascripts/echarts-all-3.js"></script>
<script type="text/javascript">
// 基于准备好的dom，初始化echarts实例
var myChart1 = echarts.init(document.getElementById('pie'));

// 指定图表的配置项和数据
var option1 = {
    title : {
        text: '日志访问来源',
        //subtext : '纯属虚构',
        x:'center'
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        left: 'left',
        data: ['1','2','3','4','5']
    },
    series : [
        {
            name: '访问来源',
            type: 'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:[
                {value:335, name:'1'},
                {value:310, name:'2'},
                {value:234, name:'3'},
                {value:135, name:'4'},
                {value:1548, name:'5'}
            ],
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

  myChart1.setOption(option1);

setInterval(function (){
    var dataObj = JSON.parse(sessionStorage.getItem("data"));
    var newData = new Array();
    Object.keys(dataObj).forEach(function(i){
        newData.push({
            value:dataObj[i],
            name:i
        });
    })
    option1.series[0].data = newData;
    myChart1.setOption(option1);
}, 1000);

</script>